# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: inkyu

from collections import namedtuple

FEATURE_ROW_FIELDS = [
    'time',
    'time_hr',
    'ask0_0',
    'askt_0',
    'bid0_0',
    'bidt_0',
    'ask0_1',
    'askt_1',
    'bid0_1',
    'bidt_1',
    'ask_basis_ma',
    'bid_basis_ma'
]
_FeatureRow = namedtuple('FeatureRow', FEATURE_ROW_FIELDS)


class FeatureRow(_FeatureRow):
  @staticmethod
  def get_header():
    return 'header_feature_dump,%s' % ','.join(FEATURE_ROW_FIELDS)

  def to_csv(self):
    return ('"FEATURE_DUMP",%d,"%s",'
            '%f,%f,%f,%f,%f,%f,%f,%f,%f,%f' % (self.time,
                                               self.time_hr,
                                               self.ask0_0,
                                               self.askt_0,
                                               self.bid0_0,
                                               self.bidt_0,
                                               self.ask0_1,
                                               self.askt_1,
                                               self.bid0_1,
                                               self.bidt_1,
                                               self.ask_basis_ma,
                                               self.bid_basis_ma))

  def to_log_string(self):
    return '\n' + self.to_csv()
